<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sd" uri="/struts-dojo-tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
<s:head theme="xhtml"/>
<sd:head debug="true" locale="zh" parseContent="true" extraLocales="en-us,zh-cn,de-de"/>
<meta charset="utf-8">
<title>添加帐号——人员管理——鑫四合珠宝管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="huyuzhu">
<!-- Le styles -->
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/css/base.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/css/main.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.placeholder.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-modal.js"></script>
<script type="text/javascript">
<s:if test="message!=null">
	$(document).ready(function(){
		$("#myModal").modal('show');
	});
</s:if>

function add(){
	clear();
	
	var username = $.trim($("#Loginid").val());
	 if(username=="") {
		$("#LoginidMsg").html("登录名不能为空!");
	  	return false;
	 }
	 else if( /^\d.*$/.test( username ) ){
	  //用户名不能以数字开头
	  $("#LoginidMsg").html("登录名不能以数字开头!");
		return false;
	 }
	 else if(username.length<6 || username.length>20 ){
	  //合法长度为6-18个字符
	  $("#LoginidMsg").html("登录名合法长度为6-20个字符!");
		 return false;
	 }
	  else if(! /^\w+$/.test( username ) ){
	  //用户名只能包含_,英文字母，数字
	  $("#LoginidMsg").html("登录名只能包含_,英文字母，数字!");
		  return false;
	 }
	 else if(! /^([a-z]|[A-Z])[0-9a-zA-Z_]+$/.test( username ) ){
	  //用户名只能英文字母开头
		 return false;
	 }
	 else if(!(/[0-9a-zA-Z]+$/.test( username ))){
	  //用户名只能英文字母或数字结尾
		 return false;
	 }
	
	var userType = $("#UserType").val();
	if(userType==0){
		$("#UserTypeMsg").html("请选择用户角色!");
		return false;
	}
	var gender = $("#Gender").val();
	if(gender==0){
		$("#GenderMsg").html("请选择用户性别!");
		return false;
	}
	$("#AddForm").submit();
} 

function clear(){
	$("#LoginidMsg").html("");
	$("#NameMsg").html("");
	$("#UserTypeMsg").html("");
	$("#GenderMsg").html("");
	$("#TelephoneMsg").html("");
	$("#QQMsg").html("");
	$("#EMailMsg").html("");
	$("#EnrollTimeMsg").html("");
	$("#RemarkMsg").html("");
	$("#message").html("");
}
</script>
</head>
<body>
<!-- 头部 -->
<s:include value="../header.jsp"/>
<!-- 主内容区开始 -->
<div class="conBox clearfix">
  <s:include value="menu.jsp">
	<s:param name="menuIndex" value="1"/>
  </s:include>
  <div class="mainBox">
    <h1>添加帐号</h1>
    <s:form id="AddForm" action="addingUser" cssClass="form-horizontal">
      <div class="control-group">
        <label class="control-label" for="ID">登录名：</label>
        <div class="controls">
          <s:textfield name="user.loginid" id="Loginid"/><span id="LoginidMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="Name">姓名：</label>
        <div class="controls">
          <s:textfield name="user.userName" id="Name"/><span id="NameMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="">角色：</label>
        <div class="controls">
          <s:select name="user.userType" list="statisticsList" id="UserType" listKey="type" cssClass="span2" listValue="typeName" headerKey="0" headerValue="请选择用户类型"/>
          <span id="UserTypeMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label">性别：</label>
        <div class="controls">
          <s:select name="user.gender" list="#{'1':'男 ', '2':'女 '}" id="Gender"  cssClass="span2" headerKey="0" headerValue="请选择性别"/>
          <span id="GenderMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="phone">联系电话：</label>
        <div class="controls">
          <s:textfield name="user.telephone" id="Phone"/>
          <span id="TelephoneMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="QQ">QQ：</label>
        <div class="controls">
          <s:textfield name="user.qq" id="QQ"/>
          <span id="QQMsg" class="help-inline  tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="email">电子邮箱：</label>
        <div class="controls">
         <s:textfield name="user.email" id="EMail"/>
         <span id="EMailMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="time1">入职时间：</label>
        <div class="controls">
        <sd:datetimepicker name="user.enrollTime" displayFormat="yyyy-MM-dd" id="EnrollTime" value="today"/>
        <span id="EnrollTimeMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="Description">备注：</label>
        <div class="controls">
          <s:textarea name="user.remark" cssClass="input-xlarge" id="Remark" rows="5"/>
          <span id="RemarkMsg" class="help-inline tred"></span>
        </div>
      </div>
      <div class="form-actions">
      	<input type="button" class="btn btn-primary" value="保存" onclick="add();"/>
        <s:reset cssClass="btn" value="重置"/>
        <s:a action="queryUserList" cssClass="btn">返回</s:a>
      </div>
    </s:form>
  </div>
</div>
<!-- 主内容区结束 --> 
<!-- 尾部 -->
<s:include value="../bottom.jsp"/>

<div class="modal hide fade" id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>操作提示</h3>
  </div>
  <div class="modal-body">
    <p><s:property  value="message"/></p>
  </div>
  <div class="modal-footer">
    <a href="#" class="btn btn-primary" data-dismiss="modal">确定</a>
  </div>
</div>

</body>
</html>